//
//  AppData.m
//  MJApp
//
//  Created by 王亮 on 15/8/25.
//  Copyright (c) 2015年 王亮. All rights reserved.
//

#import "AppData.h"
#import "WLHttpRequestAfter.h"

@interface AppData ()

@property(nonatomic,strong)NSMutableDictionary *blockDic;

@end

@implementation AppData

- (NSMutableDictionary *)blockDic {
    
    if (!_blockDic) {
        
        _blockDic = [NSMutableDictionary dictionary];
    }
    return _blockDic;
}

+ (instancetype)shareData {
    
    static AppData *shareData = nil;
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        
        shareData = [[AppData alloc] init];
    });
    return shareData;
}

//banner
- (void)bannerWithInfo:(NSDictionary *)dic withFinishBlock:(DataSuccessBlock)block {
    
    self.blockDic[@"banner"] = block;
    [WLHttpRequestAfter bannerGetBannerWithParam:dic usingSucessBlock:^(BOOL isSucess, NSDictionary *resultDictionary) {
        
        block(resultDictionary);
    } andFailureBlock:^(NSError *resultError) {
        
    }];
}

//4个话题
- (void)topicWithInfo:(NSDictionary *)dic withFinishBlock:(DataSuccessBlock)block {
    
    self.blockDic[@"topic"] = block;
    [WLHttpRequestAfter userGetTopicWithParam:dic usingSucessBlock:^(BOOL isSucess, NSDictionary *resultDictionary) {
        
        block(resultDictionary);
    } andFailureBlock:^(NSError *resultError) {
        
    }];
}

//动态list
- (void)trendListWithInfo:(NSDictionary *)dic withFinishBlock:(DataSuccessBlock)block {
 
    self.blockDic[@"trend_list"] = block;
    [WLHttpRequestAfter userGetTrendWithParam:dic usingSucessBlock:^(BOOL isSucess, NSDictionary *resultDictionary) {
        
        block(resultDictionary);
    } andFailureBlock:^(NSError *resultError) {
        
    }];
}

//登录
- (void)loginWithInfo:(NSDictionary *)dic withFinishBlock:(DataSuccessBlock)block{
    
    self.blockDic[@"login"] = block;
    [WLHttpRequestAfter userLoginWithParam:dic usingSucessBlock:^(BOOL isSucess, NSDictionary *resultDictionary) {
        
        block(resultDictionary);
    } andFailureBlock:^(NSError *resultError) {
        
    }];
}

//手机短信验证码
- (void)codeWithInfo:(NSDictionary *)dic withFinishBlock:(DataSuccessBlock)block {
    
    self.blockDic[@"code"] = block;
    [WLHttpRequestAfter userSendRangCodeWithParam:dic usingSucessBlock:^(BOOL isSucess, NSDictionary *resultDictionary) {
        
        block(resultDictionary);
    } andFailureBlock:^(NSError *resultError) {
        
    }];
}

//注册
- (void)registerWithInfo:(NSDictionary *)dic withFinishBlock:(DataSuccessBlock)block {
    
    self.blockDic[@"register"] = block;
    [WLHttpRequestAfter userRegisterWithParam:dic usingSucessBlock:^(BOOL isSucess, NSDictionary *resultDictionary) {
        
        block(resultDictionary);
    } andFailureBlock:^(NSError *resultError) {
        
    }];
}

//找回密码
- (void)findWithInfo:(NSDictionary *)dic withFinishBlock:(DataSuccessBlock)block {
    
    self.blockDic[@"find_password"] = block;
    [WLHttpRequestAfter userFindPasswordWithParam:dic usingSucessBlock:^(BOOL isSucess, NSDictionary *resultDictionary) {
        
        block(resultDictionary);
    } andFailureBlock:^(NSError *resultError) {
        
    }];
}

@end
